var jdSelect = (function() {
	return {
		// 单选 参数：id [{val:1,name:'judian'}] (selected) => {}
		JdSelectRadioInit(id,objarr,callback) {
	        $(id).html('<i class="d-select-img"></i><input readonly class="select-ul-checked"/><ul class="select-down-ul"></ul>')
	        let listr = ``
	        objarr.forEach(item => {
	            listr += `<li data-val=${item.val} data-name=${item.name}><span class="iconfont">&#xe601;</span>${item.name}</li>`
	        })
	        $(id).find('ul').html(listr)
	        $(`${id} .select-ul-checked`).val(objarr[0].name)
	        $(`${id} ul li`).eq(0).addClass('active')
	        // $(id).click(function() {
	        // 	debugger
	        //     $(this).find('.select-down-ul').toggle()
	        // })
	        // 解决点击事件被调用两次的情况
	        $(".j-dialog-content").off('click',id).on('click',id,function(e) {
	        	$(this).find('.select-down-ul').toggle()
	        	e.stopPropagation()
	        })
	        $(`${id} ul li`).click(function() {
	            $(this).addClass("active").siblings('li').removeClass('active')
	            let name = $(this).data('name')
	            $(`${id} .select-ul-checked`).val(name)
	            callback({name:name,val:$(this).data('val')})
	        })
	        $(document).click(function (event) {
	            var x1 = $(id); // 设置目标区域
	            // console.log(event)
	            if (!x1.is(event.target) && x1.has(event.target).length === 0) {
	                // $("#jnotic_user").hide()
	                $(`${id} .select-down-ul`).hide()
	            }
	        })
	    },
	    // 下拉框单选回显
	    setSelectRadio(id,dataarr,val) {
	    	let _index = 0
	    	dataarr.forEach((item,index) => {
	    		if (item.val == val) {
	    			_index = index
	    		}
	    	})
	    	$(`${id} .select-ul-checked`).val(dataarr[_index].name)
	        $(`${id} ul li`).eq(_index).addClass('active').siblings('li').removeClass('active')
	    },
	    // 下拉框单选重置
	    resetSelectRadio(id,initData) {
	    	$(`${id} .select-ul-checked`).val(initData)
	        $(`${id} ul li`).eq(0).addClass('active').siblings('li').removeClass('active')
	    }
	}
}())



